//
//  ViewController.swift
//  PageMenuNoStoryboardConfigurationDemo
//
//  Created by Matthew York on 3/6/17.
//  Copyright © 2017 UACAPS. All rights reserved.
//

import UIKit
import PageMenu

class ViewController: UIViewController {

    var pageMenu: CAPSPageMenu?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        setupPageMenu()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func setupPageMenu() {
        //Create controllers
        let colors = [UIColor.black, UIColor.blue, UIColor.red]
        let controllers = colors.map { (color: UIColor) -> UIViewController in
            let controller = UIViewController()
            controller.view.backgroundColor = color
            return controller
        }
        
        //Create page menu
//        self.pageMenu = CAPSPageMenu(viewControllers: controllers, frame: CGRect.init(x: 0, y: 64, width: 320, height: 320), configuration: dummyConfiguration())
        self.view.frame = CGRect(x: 0, y: 44, width: 320, height: 300)
        self.pageMenu = CAPSPageMenu(viewControllers: controllers, in: self, with: dummyConfiguration())
    }
    
    func dummyConfiguration() -> CAPSPageMenuConfiguration {
        let configuration = CAPSPageMenuConfiguration()
        configuration.menuItemWidth = 60
        configuration.menuMargin = 1
        configuration.scrollMenuBackgroundColor = .white
        configuration.selectedMenuItemLabelColor = .black
        configuration.unselectedMenuItemLabelColor = .gray
        configuration.selectionIndicatorHeight = 2
        configuration.menuItemSeparatorRoundEdges = true
        configuration.selectionIndicatorColor = .black
        configuration.indicatorCustomWidth = 20
        configuration.menuIsScrollEnable = false
        configuration.centerMenuItems = true
        return configuration
    }
}
